home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / snip0493.zip / PRTSTAT.C < prev    next >
C/C++ Source or Header  |  1993-04-05  |  1KB  |  69 lines

  1. /*
  2. **  PRTSTAT.H - Header file for PRTSTAT.C
  3. */
  4.  
  5. #ifndef PRTSTAT_H
  6.  #define PRTSTAT_H
  7.  
  8. struct PrStatus {
  9.       unsigned int timeout  : 1;
  10.       unsigned int unused   : 2;
  11.       unsigned int IOerror  : 1;
  12.       unsigned int selected : 1;
  13.       unsigned int paperout : 1;
  14.       unsigned int ack      : 1;
  15.       unsigned int notbusy  : 1;
  16. };
  17.  
  18. int prtstat(unsigned int);
  19.  
  20. #endif
  21.  
  22. /*** End of PRTSTAT.H *******************************************************/
  23.  
  24. /*
  25. **  PRTSTAT.C - Determine printer status
  26. **
  27. **  public domain by Bob Stout
  28. */
  29.  
  30. #include <dos.h>
  31.  
  32. #ifndef PRTSTAT_H
  33.  #include "prtstat.h"
  34. #endif
  35.  
  36. /*
  37. **  prtstat() - Call with printer number (0 = LPT1, 1 = LPT2, 2 = LPT3)
  38. **
  39. **  Returns status which can be mapped to a PrStatus struct
  40. */
  41.  
  42. int prtstat(unsigned int printer_no)
  43. {
  44.       union REGS regs;
  45.  
  46.       regs.h.ah = 2;
  47.       regs.x.dx = printer_no;
  48.       int86(0x17, ®s, ®s);
  49.       return regs.h.ah;
  50. }
  51.  
  52. #ifdef TEST
  53.  
  54. #include <stdio.h>
  55.  
  56. #define show(x) printf(#x" is %strue (LPT1)\n", mystat.x ? "" : "not ");
  57.  
  58. void main(void)
  59. {
  60.       struct PrStatus mystat;
  61.  
  62.       *((int *)&mystat) = prtstat(0);
  63.       show(notbusy);
  64.       show(selected);
  65.       show(paperout);
  66. }
  67.  
  68. #endif
  69.